package net.pm.core.entities.db;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import net.pm.core.entities.PMCommandEntity;

import com.fasterxml.jackson.annotation.JsonIgnore;


/**
 * The persistent class for the orderinfo database table.
 * 订单
 */
@Entity
@Table(name="orderinfo")
public class Orderinfo extends PMCommandEntity<Orderinfo> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8501751110611347831L;
	private Long id;
	private Boolean isDelete;
	private String orderNo;
	private Pmuser orderUser;
	private Date orderTime;
	private Date planBeginDate;
	private Date planEndDate;
	private Integer planNumber;
	private Short status;
	private Product product;
	private Guestinfo guestinfo;
	private Set<Orderinfolog> orderinfologs;

	//'计划单状态 :0等待生产,1生产中,2生产完成,3生产失败,4生产取消,'
	public static final Short STATUS_WAIT = Short.valueOf("0").shortValue();
	public static final Short STATUS_PRODUCE = Short.valueOf("1").shortValue();
	public static final Short STATUS_FINISH = Short.valueOf("2").shortValue();
	public static final Short STATUS_FAILED = Short.valueOf("3").shortValue();
	public static final Short STATUS_CANCEL = Short.valueOf("4").shortValue();
	
	/**
	 * 默认显示订单状态为0等待生产,1生产中的订单
	 */
	public static final Short STATUS_DEFAULT_DISPLAY = Short.valueOf("5").shortValue();
	/**
	 * 显示全部的订单状态
	 */
	public static final Short STATUS_ALL_DISPLAY = Short.valueOf("6").shortValue();
	
    public Orderinfo() {
    }

    
	public Orderinfo(Long id) {
		super();
		this.id = id;
	}


	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(unique=true, nullable=false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(nullable=false)
	public Boolean getIsDelete() {
		return this.isDelete;
	}

	public void setIsDelete(Boolean isDelete) {
		this.isDelete = isDelete;
	}


	@Column(nullable=false, length=30)
	public String getOrderNo() {
		return this.orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}


	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="OrderUserId", nullable=false)
	public Pmuser getOrderUser() {
		return this.orderUser;
	}

	public void setOrderUser(Pmuser orderUser) {
		this.orderUser = orderUser;
	}

	@Temporal( TemporalType.TIMESTAMP)
	@Column(nullable=false)
    public Date getOrderTime() {
		return orderTime;
	}


	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}


	@Temporal( TemporalType.TIMESTAMP)
	@Column(nullable=false)
	public Date getPlanBeginDate() {
		return this.planBeginDate;
	}

	public void setPlanBeginDate(Date planBeginDate) {
		this.planBeginDate = planBeginDate;
	}


    @Temporal( TemporalType.TIMESTAMP)
	@Column(nullable=false)
	public Date getPlanEndDate() {
		return this.planEndDate;
	}

	public void setPlanEndDate(Date planEndDate) {
		this.planEndDate = planEndDate;
	}


	@Column(nullable=false)
	public Integer getPlanNumber() {
		return this.planNumber;
	}

	public void setPlanNumber(Integer planNumber) {
		this.planNumber = planNumber;
	}


	@Column(nullable=false)
	public Short getStatus() {
		return this.status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}


	//bi-directional many-to-one association to Product
	@ManyToOne
	@JoinColumn(name="ProductId", nullable=false)
	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}
	

	//bi-directional many-to-one association to Guestinfo
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="GuestId", nullable=false)
	public Guestinfo getGuestinfo() {
		return this.guestinfo;
	}

	public void setGuestinfo(Guestinfo guestinfo) {
		this.guestinfo = guestinfo;
	}
	

	//bi-directional many-to-one association to Orderinfolog
	@OneToMany(mappedBy="orderinfo",fetch=FetchType.LAZY)
	@JsonIgnore
	public Set<Orderinfolog> getOrderinfologs() {
		return this.orderinfologs;
	}

	public void setOrderinfologs(Set<Orderinfolog> orderinfologs) {
		this.orderinfologs = orderinfologs;
	}
	

	@Override
	public int compareTo(Orderinfo o) {
		// TODO Auto-generated method stub
		return 0;
	}
	
}